﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
using System.Xml.Serialization;
using System.IO;

namespace Editor {
	/// <summary>
	/// HomePage.xaml 的交互逻辑
	/// </summary>
	public partial class HomePage : Page {
		public HomePage() {
			InitializeComponent();
			CollectionViewSource customerSource = (CollectionViewSource)this.FindResource("web_drugclassViewSource");
			customerSource.Source = new dbDataSetTableAdapters.web_drugclassTableAdapter().GetDataByParent(0);
		}

		private void treeView1_Expanded(object sender, RoutedEventArgs e) {
			var item = e.OriginalSource as TreeViewItem;
			var data = item.DataContext as DataRowView;
			var id = Convert.ToInt32(data["i_id"]);
			document doc = new document();
			doc.title = "测试内容<sub>1</sub>";
			doc.create = "2012-09";
			doc.edit = "2012-11";
			doc.content = @"<table width=""700"" align=""center"" class=""MainText"" id=""tb_enable"" border=""0"">
		<tr>
			<td align=""right"" width=""80"" valign=""top"">
				<b>输入注册码：</b>
			</td>
			<td>
				<input name=""txtRegCode"" type=""text"" id=""txtRegCode"" class=""text"" style=""width:490px;"" /><br>
				<span class=""GrayMainText"">软件注册码可以从美康产品光盘上得到，如果没有，请及时致电美康客户中心。</span>
			</td>
			<td width=""20"" valign=""top"">
				<input type=""submit"" name=""Button1"" value=""生成唯一码"" id=""Button1"" class=""button"" />
			</td>
		</tr>
		<tr>
			<td align=""right"" valign=""top"">
				<b>获取唯一码：</b>
			</td>
			<td>
				<textarea name=""txtWeiyiCode"" rows=""2"" cols=""20"" id=""txtWeiyiCode"" class=""text"" style=""height:42px;width:490px;""></textarea><br />
				<span class=""GrayMainText"">唯一码是证明您所安装产品为合法正版的唯一标识，请勿随意修改。</span>
			</td>
			<td width=""20"" valign=""top"">
				<input type=""button"" class=""button"" value=""复制唯一码"" onclick=""oCopy(document.getElementById('txtWeiyiCode'));"" id=""btn_copy"" />
			</td>
		</tr>
		<tr>
			<td align=""right"" valign=""top"">
				<b>输入激活码：</b>
			</td>
			<td>
				<textarea name=""txtJiHuo"" rows=""2"" cols=""20"" id=""txtJiHuo"" class=""text"" style=""height:86px;width:490px;""></textarea><br />
				<span class=""GrayMainText"">激活码和您安装的产品一一对应，只有从美康公司产品注册网站获得正确的激活码后才能正确完成产品注册，保证您的合法权益和使用安全。</span>
			</td>
			<td width=""20"" valign=""top"">
				<input type=""submit"" name=""btnReg"" value=""产品注册"" onclick=""showFlash();"" id=""btnReg"" class=""button"" />
			</td>
		</tr>
	</table>
	<table width=""700"" align=""center"" class=""MainText"" cellpadding=""0"" cellspacing=""0"" style=""padding-left: 4px;"">
		<tr>
			<td colspan=""2"">
				<b>注册说明：</b>
			</td>
		</tr>
		<tr>
			<td width=""20"" align=""right"" valign=""top"">
				1.
			</td>
			<td>
				请将<span style=""color: FF6600;"">注册码</span>填入相应文本框，然后点击<span style=""color: #FF6600;"">生成唯一码</span>按钮。会在唯一码文本框生成<span style=""color: #FF6600;"">唯一码</span>
			</td>
		</tr>
		<tr>
			<td align=""right"" valign=""top"">
				2.
			</td>
			<td>
				访问美康产品注册网址：<a href=""http://nreg.mcdexonline.com/Regs.aspx"" target=""_blank"" class=""LinkBtnNoWrap"" style=""text-decoration: underline;"">http://nreg.mcdexonline.com/Regs.aspx</a>，将生成的<span style=""color: #FF6600;"">唯一码</span>按照要求复制。
			</td>
		</tr>
		<tr>
			<td align=""right"" valign=""top"">
				3.
			</td>
			<td>
				将通过美康产品注册网获得的<span style=""color: #FF6600;"">激活码</span>复制到相应文本框。点击<span style=""color: #FF6600;"">产品注册</span>按钮，即可完成产品注册。
			</td>
		</tr>
		<tr>
			<td align=""right"" valign=""top"">
				4.
			</td>
			<td>
				一个注册码只能注册一台服务器。如果使用同一个注册码注册多台服务器将不能获取有效激活码。
			</td>
		</tr>
		<tr>
			<td align=""right"" valign=""top"">
				5.
			</td>
			<td>
				激活码需要登录美康产品注册网站进行联网注册才能取得。
			</td>
		</tr>
		<tr>
			<td align=""right"" valign=""top"">
				6.
			</td>
			<td>
				如果在软件注册过程中有任何疑问或问题请联系美康产品客服人员。<br>
				产品服务部电话：<span style=""font-family: verdana; color: Black;""><b>028-85183848</b></span>&nbsp;&nbsp;电邮：<a class=""LinkBtnNoWrap"" style=""text-decoration: underline;"" href=""mailto:mcdex@medicom.com.cn"">mcdex@medicom.com.cn</a>
			</td>
		</tr>
	</table>";

			doc.content = new paragraph[] {
			new paragraph{ title="【注意事项】" ,content = "test"},
			new paragraph{ title="【国外专科用药信息参考】" ,content = new paragraph{ title="[儿童]" ,content = "test"}}
			};
			XmlSerializer mySerializer = new XmlSerializer(typeof(document));
			// To write to a file, create a StreamWriter object.

			StreamWriter myWriter = new StreamWriter("myFileName.xml");
			mySerializer.Serialize(myWriter, doc);
			myWriter.Close();

		}
	}
}
